-
Notifications
You must be signed in to change notification settings - Fork 141
Open
Labels
ClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.Monitor - ExporterMonitor OpenTelemetry ExporterMonitor OpenTelemetry Exportercustomer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-team-triageWorkflow: This issue needs the team to triage.Workflow: This issue needs the team to triage.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
Description
Question
How must the OpenTelemetry exporter be configured so that the traces will be sent to Azure Monitor?
Is it possible to add an example for the use case or explain how it can be realized with the available functionality.
Problem
There is no example in the documention or in the code. Other sdk's for azure provide a method UseAzureMonitor() and they work with the environment variable APPLICATIONINSIGHTS_CONNECTION_STRING.
https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-enable?tabs=aspnetcore
Situation
Connection string with following structure is known:
"InstrumentationKey=my_key;IngestionEndpoint=my_ingestion_endpoint;LiveEndpoint=my_live_endpoint;ApplicationId=my_app_id"
Following code don't work:
opentelemetry::sdk::resource::ResourceAttributes attributes = {
{"service.name", serviceName},
{"service.version", serviceVersion}
};
auto resource = opentelemetry::sdk::resource::Resource::Create(attributes);
opentelemetry::exporter::otlp::OtlpHttpExporterOptions options;
options.url = "my_live_endpoint";
options.http_headers.insert(std::make_pair("InstrumentationKey", "my_key"));
options.http_headers.insert(std::make_pair("ApplicationId", "my_app_id"));
// Create OTLP HTTP exporter
auto exporter = opentelemetry::exporter::otlp::OtlpHttpExporterFactory::Create(options);
// Create test processor
auto processor = opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create(std::move(exporter));
// Create tracer provider
std::shared_ptr<opentelemetry::trace::TracerProvider> tracerProviderOpenTelemetry = opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor), resource);
// Create Azure tracer provider
auto tracerProviderAzure = Azure::Core::Tracing::OpenTelemetry::OpenTelemetryProvider::Create(tracerProviderOpenTelemetry);
// Create Azure Tracer
auto tracerAzure = Azure::Core::Tracing::_internal::TracerProviderImplGetter::TracerImplFromTracer(tracerProviderAzure)->CreateTracer(serviceName, serviceVersion);
auto span = tracerAzure->CreateSpan("AZURE_SPAN", {});
span->AddAttribute("test.suite", "Hello World!");
span->End({});
Metadata
Metadata
Assignees
Labels
ClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.Monitor - ExporterMonitor OpenTelemetry ExporterMonitor OpenTelemetry Exportercustomer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-team-triageWorkflow: This issue needs the team to triage.Workflow: This issue needs the team to triage.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that