{"id":13451310,"url":"https://github.com/jaegertracing/jaeger-client-csharp","last_synced_at":"2025-03-23T18:32:14.064Z","repository":{"id":45075313,"uuid":"122382522","full_name":"jaegertracing/jaeger-client-csharp","owner":"jaegertracing","description":"🛑 This library is DEPRECATED!","archived":true,"fork":false,"pushed_at":"2022-01-10T19:38:08.000Z","size":995,"stargazers_count":302,"open_issues_count":0,"forks_count":67,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-13T05:45:55.625Z","etag":null,"topics":["jaegertracing","opentracing","tracing"],"latest_commit_sha":null,"homepage":"https://jaegertracing.io/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaegertracing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2018-02-21T19:25:24.000Z","updated_at":"2024-10-29T19:14:21.000Z","dependencies_parsed_at":"2022-08-26T09:41:37.855Z","dependency_job_id":null,"html_url":"https://github.com/jaegertracing/jaeger-client-csharp","commit_stats":null,"previous_names":["chatham/letstrace"],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaegertracing%2Fjaeger-client-csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaegertracing%2Fjaeger-client-csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaegertracing%2Fjaeger-client-csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaegertracing%2Fjaeger-client-csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaegertracing","download_url":"https://codeload.github.com/jaegertracing/jaeger-client-csharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245149537,"owners_count":20568918,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jaegertracing","opentracing","tracing"],"created_at":"2024-07-31T07:00:51.587Z","updated_at":"2025-03-23T18:32:09.045Z","avatar_url":"https://github.com/jaegertracing.png","language":"C#","funding_links":[],"categories":["C\\#","Tracing","C# #"],"sub_categories":["LINQ"],"readme":"[![Build status][ci-img]][ci] [![NuGet][nuget-img]][nuget]\n\n# 🛑 This library is DEPRECATED!\n\nNo new pull requests are accepted except for security fixes.\n\nWe urge all users to migrate to [OpenTelemetry](https://opentelemetry.io/). Please refer to the [notice in the documentation](https://www.jaegertracing.io/docs/latest/client-libraries/#deprecating-jaeger-clients) for details.\n\n# C# Client for Jaeger (https://jaegertracing.io)\n\n- Implements C# [OpenTracing API](https://github.com/opentracing/opentracing-csharp)\n- Supports netstandard 2.0\n\n## Usage\nThis package contains everything you need to get up and running. The meta-package includes the following packages:\n* [Jaeger.Core](https://www.nuget.org/packages/Jaeger.Core/)\n* [Jaeger.Senders.Thrift](https://www.nuget.org/packages/Jaeger.Senders.Thrift/)\n\n### Senders\nThe implementation of `Jaeger.Core` is agnostic to any reporting endpoint and could be even used without any in case of logfile reporting. For more information about the sender concept, have a look at the sender [README](src/Jaeger.Core/Senders/README.md).\n\nThis is a list of sender implementations known to the Jaeger team:\n* [Jaeger.Senders.Thrift](src/Senders/Jaeger.Senders.Thrift/README.md) (default, included in `Jaeger`)\n* [Jaeger.Senders.Grpc](src/Senders/Jaeger.Senders.Grpc/README.md)\n\n### The Tracer\nThe following will give you a tracer that reports spans to an `ILogger` instance from `ILoggerFactory`.\n\n```C#\nusing Jaeger;\nusing Jaeger.Reporters;\nusing Jaeger.Samplers;\nusing Microsoft.Extensions.Logging;\n\nvar loggerFactory = ; // get Microsoft.Extensions.Logging ILoggerFactory\nvar serviceName = \"initExampleService\";\n\nvar reporter = new LoggingReporter(loggerFactory);\nvar sampler = new ConstSampler(true);\nvar tracer = new Tracer.Builder(serviceName)\n    .WithLoggerFactory(loggerFactory)\n    .WithReporter(reporter)\n    .WithSampler(sampler)\n    .Build();\n```\n\nThis works well if you only want to log to a logging framework. As soon as you want to also get metrics and use a real remote tracer, manually building will get hard pretty fast.\n\n`Configuration` holds only primitive values and it is designed to be used with configuration files or when configuration is provided in environmental variables.\n\n```C#\nusing Jaeger;\nusing Jaeger.Samplers;\nusing Microsoft.Extensions.Logging;\n\nvar loggerFactory = ; // get Microsoft.Extensions.Logging ILoggerFactory\nvar serviceName = \"initExampleService\";\n\nConfiguration.SenderConfiguration.DefaultSenderResolver = new SenderResolver(loggerFactory)\n\t.RegisterSenderFactory\u003cThriftSenderFactory\u003e();\nConfiguration config = new Configuration(\"myServiceName\")\n\t.WithSampler(...)   // optional, defaults to RemoteControlledSampler with HttpSamplingManager on localhost:5778\n\t.WithReporter(...); // optional, defaults to RemoteReporter with UdpSender on localhost:6831 when ThriftSenderFactory is registered\n\nITracer tracer = config.GetTracer();\n```\n\nThe config objects lazily builds and configures Jaeger Tracer. Multiple calls to GetTracer() return the same instance.\n\n#### Notice\nThe `ThriftSenderFactory` is defined as part of the NuGET package `Jaeger.Senders.Thrift`. This is usually included through the meta-package `Jaeger`. If you do not want to add a dependency on `ApacheThrift` when using other `Jaeger.Senders.*` packages or when defining your own `ISender`/`ISenderFactory`, use the package `Jaeger.Core` directly instead of `Jaeger`.\n\nBy default, `Configuration.SenderConfiguration.DefaultSenderResolver` does NOT contain any `ISenderFactory` instances since `Jaeger.Core` is agnostic of any `ISender` implementation. All calls to `SenderResolver.Resolve` will return `NoopSender.Instance`.\n\n#### Configuration via Environment\n\nIt is also possible to obtain a `Jaeger.Configuration` object configured using properties specified\nas environment variables or system properties. A value specified as a system property will override a value\nspecified as an environment variable for the same property name.\n\n```C#\nConfiguration config = Configuration.FromEnv();\n```\n\nThe property names are:\n\nProperty | Required | Description\n--- | --- | ---\nJAEGER_SERVICE_NAME | yes | The service name\nJAEGER_AGENT_HOST | no | The hostname for communicating with agent via UDP\nJAEGER_AGENT_PORT | no | The port for communicating with agent via UDP\nJAEGER_GRPC_TARGET | no | The target for communicating with collector via GRPC, see https://github.com/grpc/grpc/blob/master/doc/naming.md\nJAEGER_GRPC_ROOT_CERTIFICATE | no | The root certificate file used to check the server side certificate from GRPC collector (roots.pem)\nJAEGER_GRPC_CLIENT_CHAIN | no | The client certificate chain file used to create a trusted TLS connection to the GRPC collector (client.pem)\nJAEGER_GRPC_CLIENT_KEY | no | The client private key file used to create a trusted TLS connection to the GRPC collector (client.key)\nJAEGER_ENDPOINT | no | The traces endpoint, in case the client should connect directly to the Collector, like http://jaeger-collector:14268/api/traces\nJAEGER_AUTH_TOKEN | no | Authentication Token to send as \"Bearer\" to the endpoint\nJAEGER_USER | no | Username to send as part of \"Basic\" authentication to the endpoint\nJAEGER_PASSWORD | no | Password to send as part of \"Basic\" authentication to the endpoint\nJAEGER_PROPAGATION | no | Comma separated list of formats to use for propagating the trace context. Defaults to the standard Jaeger format. Valid values are **jaeger** and **b3**\nJAEGER_REPORTER_LOG_SPANS | no | Whether the reporter should also log the spans\nJAEGER_REPORTER_MAX_QUEUE_SIZE | no | The reporter's maximum queue size\nJAEGER_REPORTER_FLUSH_INTERVAL | no | The reporter's flush interval (ms)\nJAEGER_SAMPLER_TYPE | no | The sampler type\nJAEGER_SAMPLER_PARAM | no | The sampler parameter (double)\nJAEGER_SAMPLER_MANAGER_HOST_PORT | no | (DEPRECATED) The host name and port when using the remote controlled sampler\nJAEGER_SAMPLING_ENDPOINT | no | The url for the remote sampling conf when using sampler type remote. Default is http://127.0.0.1:5778/sampling\nJAEGER_TAGS | no | A comma separated list of `name = value` tracer level tags, which get added to all reported spans. The value can also refer to an environment variable using the format `${envVarName:default}`, where the `:default` is optional, and identifies a value to be used if the environment variable cannot be found\nJAEGER_SENDER_FACTORY | no | The name of the sender factory to use if multiple are available\nJAEGER_TRACEID_128BIT | no | Whether to use 128bit TraceID instead of 64bit\n\nSetting `JAEGER_AGENT_HOST`/`JAEGER_AGENT_PORT` will make the client send traces to the agent via `UdpSender`.\nIf the `JAEGER_ENDPOINT` environment variable is also set, the traces are sent to the endpoint, effectively making\nthe `JAEGER_AGENT_*` vars ineffective.\n\nWhen the `JAEGER_ENDPOINT` is set, the `HttpSender` is used when submitting traces to a remote\nendpoint, usually served by a Jaeger Collector. If the endpoint is secured, a HTTP Basic Authentication\ncan be performed by setting the related environment vars. Similarly, if the endpoint expects an authentication\ntoken, like a JWT, set the `JAEGER_AUTH_TOKEN` environment variable. If the Basic Authentication environment\nvariables *and* the Auth Token environment variable are set, Basic Authentication is used.\n\n#### Reporting\nFor more information on reporting see the reporting [README](src/Jaeger.Core/Reporters/README.md)\n\n#### Sampling\nFor more information on sampling see the sampling [README](src/Jaeger.Core/Samplers/README.md)\n\n#### Extracting Span Information\nWhen your code is called you might want to pull current trace information out of calling information before building and starting a span. This allows you to link your span into a current trace and track its relation to other spans. By default text map and http headers are supported. More support is planned for the future as well as allowing custom extractors.\n\n```C#\nusing OpenTracing.Propagation; // where you get Format from\n\nvar callingHeaders = new TextMapExtractAdapter(...); // get the calling headers\n\nvar callingSpanContext = tracer.Extract(BuiltinFormats.HttpHeaders, callingHeaders);\n```\nYou can then use the callingSpanContext when [adding references](#adding-references) with the SpanBuilder.\n\n#### Injecting Span Information\nIn order to pass along the trace information in calls so others can extract it you need to inject it into the carrier.\n\n```C#\nusing OpenTracing.Propagation; // where you get BuiltinFormats from\n\nvar spanContext = span.Context; // pulled from your current span\nvar newCallHeaders = new TextMapInjectAdapter(null); // get the calling headers\n\ntracer.Inject(spanContext, BuiltinFormats.HttpHeaders, newCallHeaders);\n```\nYou can then pass along the headers and as along as what you are calling knows how to extract that format you are good to go.\n\n### Building a Span\nBefore you start a span you will want to build it out. You can do this using the span builder. You would build a span for each operation you wanted to trace.\n\n```C#\nvar operationName = \"Get::api/values/\";\nvar builder = tracer.BuildSpan(operationName);\n```\n\n#### Adding Tags\nAny tags you add to the span builder will be added to the span on start and reported to the reporting system you have setup when the span is reported. The following types are supported as tags: `bool`, `double`, `int`, `string`.\n\n```C#\nbuilder.WithTag(\"machine.name\", \"machine1\").WithTag(\"cpu.cores\", 8);\n```\n\nSome well-known tags are defined in `OpenTracing.Tag` and can be used as follows:\n\n```C#\nusing OpenTracing.Tag;\n\nbuilder.WithTag(Tags.SpanKind, Tags.SpanKindClient).WithTag(Tags.DbType, \"sql\");\n```\n\n#### Adding References\nReferences allow you to show how this span relates to another span. You need the `SpanContext` of the span you want to reference. If you add a `child_of` reference the SpanBuilder will use that as the parent of the span being built.\n\n```C#\nbuilder.AddReference(References.FollowsFrom, spanContext);\n```\nThere also exist helper methods to simplify adding child of references.\n\n#### As Child Of\nShorthand for adding a chold of reference. You can pass in an `ISpan` or and `ISpanContext`.\n\n```C#\nbuilder.AsChildOf(iSpanOrISpanContext);\n```\n\n#### Starting the Span\nStarting the span from the span builder will figure out if there is a parent for the span, create a context for the span, and pass along all references and tags.\n\nYou can start the span right now:\n```C#\nvar span = builder.Start();\n```\n\nOr you can start it at a specific time:\n```C#\nvar startTime = DateTimeOffset.Now;\nvar span = builder.WithStartTimestamp(startTime).Start();\n```\n\nIf you want to start a span and use it as an active span, you can use a scoped span.\n```C#\nusing (var scope = builder.StartActive(true))\n{\n\tvar span = scope.Span;\n}\n```\n\nThis will automatically define the newly created span as child of the span that was active at that time. If no span was active, it will be created as root span. \nIn addition will the scope span be automatically finished when the scope ends, even if the `using`-Block throws an exception.\n\n### Spans\nAfter creating a span and before finishing it, you can add and change some information on a span.\n\n#### Baggage Items\nBaggage is key/value data that is passed along the wire and shared with other spans. You can get and set baggage data from the span object.\n\n```C#\nvar mobileVersion = span.GetBaggageItem(\"mobile.version\");\n```\n\n```C#\nspan.SetBaggageItem(\"back-end.version\", \"0.0.1\");\n```\n\n#### Logging\nYou can log structured data which allows you to tie information from what's happening along the lifetime of a span to the time that it happened. You can log a list of key/value data or an event at a specific time.\n\n```C#\nvar logData = new List\u003cKeyValuePair\u003cstring, object\u003e\u003e {\n    { \"handling number of events\", 6 },\n    { \"using legacy system\", false }\n};\n\nspan.Log(DateTimeOffset.Now, logData);\n```\nor you can pass it without a timestamp and the timestamp will be sent for you:\n```C#\nspan.Log(logData);\n```\n\nEvents are a little different in that they're just a string.\n```C#\nvar event = \"loop_finished\";\n\nspan.Log(DateTimeOffset.Now, event);\n```\nand as above you can send an event in without a timestamp:\n```C#\nspan.Log(event);\n```\n\n#### Tags\nTags can be set using `SetTag(\u003ckey\u003e, \u003cvalue\u003e)` and follows the builder [WithTag](#adding-tags) in the data types it accepts.\n\n#### Operation Name\nYou can change the operation name from what was originally set on the span when it was created.\n\n```C#\nspan.SetOperationName(\"PUT::api/values/\");\n```\n\n#### Finishing\n`Span` implements `IDisposable` so a using statement will automatically finish your span. However, you can also call `Finish`. You can either pass in the finish time or let the library handle that for you.\n\n```C#\nspan.Finish(DateTimeOffset.Now);\n```\nor\n```C#\nspan.Finish();\n```\n\n## Contributing\n\nWe welcome community contributions to this project. Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more details.\n\nBy contributing your code, you agree to license your contribution under the terms of the [APLv2](LICENSE).\n\n## License\n\nAll files are released with the [Apache 2.0 license](LICENSE).\n\n[ci-img]: https://ci.appveyor.com/api/projects/status/github/jaegertracing/jaeger-client-csharp?svg=true\n[ci]: https://ci.appveyor.com/project/jaegertracing/jaeger-client-csharp\n[nuget-img]: https://img.shields.io/nuget/v/Jaeger.svg\n[nuget]: https://www.nuget.org/packages/Jaeger/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaegertracing%2Fjaeger-client-csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaegertracing%2Fjaeger-client-csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaegertracing%2Fjaeger-client-csharp/lists"}