.NET 도움말 Opentelemetry C# (How It Works For Developers) 커티스 차우 업데이트됨:7월 28, 2025 다운로드 IronPDF NuGet 다운로드 DLL 다운로드 윈도우 설치 프로그램 무료 체험 시작하기 LLM용 사본 LLM용 사본 LLM용 마크다운 형식으로 페이지를 복사하세요 ChatGPT에서 열기 ChatGPT에 이 페이지에 대해 문의하세요 제미니에서 열기 제미니에게 이 페이지에 대해 문의하세요 Grok에서 열기 Grok에게 이 페이지에 대해 문의하세요 혼란 속에서 열기 Perplexity에게 이 페이지에 대해 문의하세요 공유하다 페이스북에 공유하기 트위터에 공유하기 LinkedIn에 공유하기 URL 복사 이메일로 기사 보내기 OpenTelemetry is a set of tools, APIs, and SDKs that work together to collect, process, and export telemetry data like traces, metrics, and logs from your applications. This tutorial aims to help beginners understand how to integrate OpenTelemetry in C# applications using the extension method, focusing on built-in metrics collection to monitor .NET applications effectively. We'll also learn about the IronPDF library for PDF generation in C#. Introduction to OpenTelemetry OpenTelemetry provides a unified way to collect all kinds of data from your applications. For .NET developers, integrating OpenTelemetry means you can monitor your applications more closely, understand how they perform in real-time, and identify issues quickly. OpenTelemetry's instrumentation library automatically enables tracing and metrics collection for .NET apps. With the metrics collected by the OpenTelemetry framework, developers gain valuable insights into the .NET runtime environment. The OpenTelemetry .NET implementation supports .NET runtime, including .NET Core and .NET Framework. It adheres to the OpenTelemetry protocol for standardized telemetry data collection. Setting Up Your Environment To start, you'll need to have the .NET SDK installed on your machine. If you're using Visual Studio, it likely came with the .NET SDK. You can check your current .NET SDK version by opening a command line and running: dotnet --version Next, create a new .NET Web project by running: dotnet new web -o MyTelemetryApp cd MyTelemetryApp dotnet new web -o MyTelemetryApp cd MyTelemetryApp SHELL This command creates a new ASP.NET Core project in a directory named MyTelemetryApp. Integrating OpenTelemetry Adding Required Packages First, add the necessary OpenTelemetry packages to your project. Open your terminal and navigate to your project directory. Then, install the following packages using the NuGet Package Manager CLI: dotnet add package OpenTelemetry -Version <version> dotnet add package OpenTelemetry.Extensions.Hosting -Version <version> dotnet add package OpenTelemetry.Instrumentation.AspNetCore -Version <version> dotnet add package OpenTelemetry.Exporter.Console -Version <version> dotnet add package OpenTelemetry -Version <version> dotnet add package OpenTelemetry.Extensions.Hosting -Version <version> dotnet add package OpenTelemetry.Instrumentation.AspNetCore -Version <version> dotnet add package OpenTelemetry.Exporter.Console -Version <version> SHELL Replace with the latest version of each package. Configuring OpenTelemetry in Your Application After adding the necessary packages, you need to configure OpenTelemetry in your application. This involves setting up the OpenTelemetry SDK and specifying what telemetry data to collect. OpenTelemetry offers instrumentation libraries for seamless integration with .NET applications. Open the Startup.cs file in your project and modify the ConfigureServices method to include OpenTelemetry as shown in the code snippet below: public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddOpenTelemetryTracing(builder => { builder.AddAspNetCoreInstrumentation() .AddHttpClientInstrumentation() .AddConsoleExporter(); }); } public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddOpenTelemetryTracing(builder => { builder.AddAspNetCoreInstrumentation() .AddHttpClientInstrumentation() .AddConsoleExporter(); }); } $vbLabelText $csharpLabel This code snippet shows how to configure OpenTelemetry to collect telemetry data from ASP.NET Core applications and HTTP client calls, and then export this data to the console. The AddAspNetCoreInstrumentation method automatically enables instrumentation for incoming HTTP requests to ASP.NET Core apps. Collecting Metrics To collect metrics, you'll also need to configure the OpenTelemetry Metrics API, focusing on metrics rather than tracing. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddOpenTelemetryMetrics(builder => { builder.AddAspNetCoreInstrumentation() .AddHttpClientInstrumentation() .AddConsoleExporter(options => options.Targets = ConsoleExporterOutputTargets.Console); }); } public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddOpenTelemetryMetrics(builder => { builder.AddAspNetCoreInstrumentation() .AddHttpClientInstrumentation() .AddConsoleExporter(options => options.Targets = ConsoleExporterOutputTargets.Console); }); } $vbLabelText $csharpLabel This setup enables the collection of built-in metrics from ASP.NET Core and HTTP client instrumentation, exporting them to the console for easy viewing. Creating Custom Metrics While OpenTelemetry automatically collects many useful metrics, you might want to collect custom metrics specific to your application. Utilizing an extension method provided by the instrumentation library not only collects telemetry automatically but also gives developers more granular control over the metrics emitted. This can be achieved by manually instrumenting your code to create and record custom metrics. var meter = new Meter("MyCustomMetrics", "1.0"); var counter = meter.CreateCounter<int>("custom_request_count", description: "Counts custom requests"); app.Use((context, next) => { counter.Add(1, new KeyValuePair<string, object>("path", context.Request.Path)); return next(); }); var meter = new Meter("MyCustomMetrics", "1.0"); var counter = meter.CreateCounter<int>("custom_request_count", description: "Counts custom requests"); app.Use((context, next) => { counter.Add(1, new KeyValuePair<string, object>("path", context.Request.Path)); return next(); }); $vbLabelText $csharpLabel This code snippet demonstrates how to create a custom metric that counts requests to your application, tagging each metric with the request path. By leveraging extension methods provided by OpenTelemetry, developers can exert more granular control over the telemetry data collection process. Testing Your Integration Run your application using the command line or Visual Studio. Make some requests to your application, either by navigating to its URL in a web browser or by using a tool like curl. You should see telemetry data, including traces and metrics, being printed to your console output. curl http://localhost:5000 curl http://localhost:5000 SHELL Introduction of IronPDF IronPDF is a powerful library for C# developers, enabling the generation, manipulation, and rendering of PDF documents directly within .NET applications. This capability is especially useful for generating reports, invoices, or any document-based outputs from web applications using HTML, services, or desktop apps. Combining IronPDF with OpenTelemetry allows developers to monitor the performance and reliability of PDF generation processes within their applications, ensuring a smooth user experience. IronPDF excels in HTML to PDF conversion, ensuring precise preservation of original layouts and styles. It's perfect for creating PDFs from web-based content such as reports, invoices, and documentation. With support for HTML files, URLs, and raw HTML strings, IronPDF easily produces high-quality PDF documents. using IronPdf; class Program { static void Main(string[] args) { var renderer = new ChromePdfRenderer(); // 1. Convert HTML String to PDF var htmlContent = "<h1>Hello, IronPDF!</h1><p>This is a PDF from an HTML string.</p>"; var pdfFromHtmlString = renderer.RenderHtmlAsPdf(htmlContent); pdfFromHtmlString.SaveAs("HTMLStringToPDF.pdf"); // 2. Convert HTML File to PDF var htmlFilePath = "path_to_your_html_file.html"; // Specify the path to your HTML file var pdfFromHtmlFile = renderer.RenderHtmlFileAsPdf(htmlFilePath); pdfFromHtmlFile.SaveAs("HTMLFileToPDF.pdf"); // 3. Convert URL to PDF var url = "http://ironpdf.com"; // Specify the URL var pdfFromUrl = renderer.RenderUrlAsPdf(url); pdfFromUrl.SaveAs("URLToPDF.pdf"); } } using IronPdf; class Program { static void Main(string[] args) { var renderer = new ChromePdfRenderer(); // 1. Convert HTML String to PDF var htmlContent = "<h1>Hello, IronPDF!</h1><p>This is a PDF from an HTML string.</p>"; var pdfFromHtmlString = renderer.RenderHtmlAsPdf(htmlContent); pdfFromHtmlString.SaveAs("HTMLStringToPDF.pdf"); // 2. Convert HTML File to PDF var htmlFilePath = "path_to_your_html_file.html"; // Specify the path to your HTML file var pdfFromHtmlFile = renderer.RenderHtmlFileAsPdf(htmlFilePath); pdfFromHtmlFile.SaveAs("HTMLFileToPDF.pdf"); // 3. Convert URL to PDF var url = "http://ironpdf.com"; // Specify the URL var pdfFromUrl = renderer.RenderUrlAsPdf(url); pdfFromUrl.SaveAs("URLToPDF.pdf"); } } $vbLabelText $csharpLabel Setting Up IronPDF First, you need to add IronPDF to your .NET project. You can do this using the NuGet Package Manager. Open your terminal and navigate to your project directory. Then, run the following command to install IronPDF: dotnet add package IronPDF dotnet add package IronPDF SHELL Generating a PDF with IronPDF and Monitoring with OpenTelemetry Below is an example of how to generate a simple PDF document and monitor the operation using OpenTelemetry. The following example assumes you have already configured OpenTelemetry in your application as shown earlier. using IronPdf; using OpenTelemetry.Trace; public class PdfService { private readonly Tracer _tracer; public PdfService(Tracer tracer) { _tracer = tracer; } public void GeneratePdf() { // Create a new activity for this operation using var activity = _tracer.StartActivity("Generate PDF"); // Simulate adding some attributes related to the operation activity?.SetTag("pdf.size", "A4"); activity?.SetTag("pdf.content", "Hello World"); try { // Initialize the PDF generator var renderer = new ChromePdfRenderer(); // Generate a PDF from HTML var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>"); // Save the PDF to a file var outputPath = "output.pdf"; pdf.SaveAs(outputPath); // Log success activity?.SetTag("pdf.status", "Success"); activity?.SetTag("pdf.outputPath", outputPath); } catch (Exception ex) { // Log any exceptions that occur during PDF generation activity?.SetTag("pdf.status", "Error"); activity?.SetTag("pdf.error", ex.Message); throw; } } } using IronPdf; using OpenTelemetry.Trace; public class PdfService { private readonly Tracer _tracer; public PdfService(Tracer tracer) { _tracer = tracer; } public void GeneratePdf() { // Create a new activity for this operation using var activity = _tracer.StartActivity("Generate PDF"); // Simulate adding some attributes related to the operation activity?.SetTag("pdf.size", "A4"); activity?.SetTag("pdf.content", "Hello World"); try { // Initialize the PDF generator var renderer = new ChromePdfRenderer(); // Generate a PDF from HTML var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>"); // Save the PDF to a file var outputPath = "output.pdf"; pdf.SaveAs(outputPath); // Log success activity?.SetTag("pdf.status", "Success"); activity?.SetTag("pdf.outputPath", outputPath); } catch (Exception ex) { // Log any exceptions that occur during PDF generation activity?.SetTag("pdf.status", "Error"); activity?.SetTag("pdf.error", ex.Message); throw; } } } $vbLabelText $csharpLabel In this example, we create a new service class PdfService that includes a method GeneratePdf for generating a PDF document. We use IronPDF's ChromePdfRenderer class to render HTML as a PDF document. With OpenTelemetry, we start a new activity named "Generate PDF" to monitor this operation. We add custom tags to the activity to provide additional context about the PDF generation process, such as the size of the PDF, the content type, and the output path. We also catch any exceptions to log errors appropriately within the same activity. Conclusion Integrating OpenTelemetry into your .NET applications allows you to collect valuable telemetry data, offering insights into your application's performance and behavior. By following the steps outlined in this tutorial, you've set up basic tracing and metrics collection for a .NET web application. Experiment further by exploring more advanced OpenTelemetry features, such as exporting telemetry data to external monitoring tools or collecting logs alongside traces and metrics. IronPDF offers a free trial of IronPDF for production to test out its full capabilities. Licenses start from as low as $399. 자주 묻는 질문 C# 개발에서 OpenTelemetry의 목적은 무엇인가요? OpenTelemetry는 추적, 메트릭, 로그와 같은 원격 분석 데이터를 수집, 처리, 내보내는 통합된 접근 방식을 제공하여 개발자가 애플리케이션 성능을 실시간으로 모니터링하고 이해할 수 있도록 지원합니다. C# 애플리케이션에 OpenTelemetry를 통합하려면 어떻게 해야 하나요? 먼저 NuGet을 통해 필요한 OpenTelemetry 패키지를 설치한 다음, OpenTelemetry 추적 및 지표를 포함하도록 'Startup.cs'의 'ConfigureServices' 메서드를 수정하여 애플리케이션을 구성합니다. C#에서 OpenTelemetry를 위한 환경을 설정하려면 어떤 단계가 필요하나요? .NET SDK가 컴퓨터에 설치되어 있는지 확인합니다. 명령줄에서 dotnet --version를 실행하여 설치 여부를 확인할 수 있습니다. HTML 콘텐츠를 사용하여 C#으로 PDF를 생성하려면 어떻게 해야 하나요? IronPDF 라이브러리의 ChromePdfRenderer 클래스를 사용하여 HTML을 PDF 문서로 렌더링한 다음 SaveAs 메서드를 사용하여 생성된 PDF를 저장할 수 있습니다. C# 애플리케이션에서 PDF 생성 프로세스를 모니터링하려면 어떻게 해야 하나요? OpenTelemetry의 Tracer를 사용하여 PDF 생성을 위한 활동을 생성하고 사용자 지정 태그를 추가하여 모니터링 목적으로 프로세스에 대한 관련 정보를 기록합니다. 사용자 지정 메트릭이란 무엇이며, C#을 사용한 OpenTelemetry에서 어떻게 사용할 수 있나요? 사용자 지정 메트릭은 OpenTelemetry의 Meter 및 Counter 클래스를 사용하여 코드를 수동으로 계측하여 수집할 수 있는 애플리케이션별 데이터 포인트입니다. C#에서 신뢰할 수 있는 PDF 생성을 보장하려면 어떻게 해야 하나요? IronPDF 라이브러리를 사용하여 PDF 문서를 안정적으로 생성, 조작 및 렌더링하세요. IronPDF는 애플리케이션에서 고품질 PDF 출력을 보장하는 강력한 기능을 제공합니다. C#으로 PDF를 생성하는 데 도움이 되는 라이브러리에 사용할 수 있는 라이선스 옵션이 있나요? IronPDF는 프로덕션 테스트를 위한 무료 평가판을 제공하며, 라이선스는 399달러부터 시작하여 개발자가 모든 기능을 살펴볼 수 있습니다. C# 애플리케이션에서 OpenTelemetry 통합을 테스트하려면 어떻게 해야 하나요? 애플리케이션을 실행하고 웹 브라우저나 curl과 같은 도구를 사용하여 요청을 한 다음 콘솔에 출력되는 추적 및 메트릭과 같은 원격 분석 데이터를 관찰합니다. 커티스 차우 지금 바로 엔지니어링 팀과 채팅하세요 기술 문서 작성자 커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다. 커티스는 개발 분야 외에도 사물 인터넷(IoT)에 깊은 관심을 가지고 있으며, 하드웨어와 소프트웨어를 통합하는 혁신적인 방법을 연구합니다. 여가 시간에는 게임을 즐기거나 디스코드 봇을 만들면서 기술에 대한 애정과 창의성을 결합합니다. 관련 기사 업데이트됨 12월 11, 2025 Bridging CLI Simplicity & .NET : Using Curl DotNet with IronPDF Jacob Mellor has bridged this gap with CurlDotNet, a library created to bring the familiarity of cURL to the .NET ecosystem. 더 읽어보기 업데이트됨 12월 20, 2025 RandomNumberGenerator C# Using the RandomNumberGenerator C# class can help take your PDF generation and editing projects to the next level 더 읽어보기 업데이트됨 12월 20, 2025 C# String Equals (How it Works for Developers) When combined with a powerful PDF library like IronPDF, switch pattern matching allows you to build smarter, cleaner logic for document processing 더 읽어보기 C# Span (How It Works For Developers)C# WebRTC (How It Works For Developers)
업데이트됨 12월 11, 2025 Bridging CLI Simplicity & .NET : Using Curl DotNet with IronPDF Jacob Mellor has bridged this gap with CurlDotNet, a library created to bring the familiarity of cURL to the .NET ecosystem. 더 읽어보기
업데이트됨 12월 20, 2025 RandomNumberGenerator C# Using the RandomNumberGenerator C# class can help take your PDF generation and editing projects to the next level 더 읽어보기
업데이트됨 12월 20, 2025 C# String Equals (How it Works for Developers) When combined with a powerful PDF library like IronPDF, switch pattern matching allows you to build smarter, cleaner logic for document processing 더 읽어보기