英文:
configure https endpoint in python opentelemetry library
问题
我有以下的代码,试图将opentelemetry跟踪发送到https OTLP端点。然而,它生成了一个证书验证错误。我理解我需要配置一个证书,但不知道如何操作。我已经成功生成了一个证书,但不知道如何在Python库中配置它。
from opentelemetry import trace
# from opentelemetry.exporter.jaeger.thrift import JaegerExporter
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
#from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
...
resource = Resource(attributes={
SERVICE_NAME: "demo"
})
provider = TracerProvider(resource=resource)
processor = BatchSpanProcessor(OTLPSpanExporter(endpoint="<endpointhost>/v1/traces", insecure=True))
provider.add_span_processor(processor)
trace.set_tracer_provider(provider)
感谢任何帮助。
英文:
i
I have the following code that tries to send opentelemetry traces to an https OTLP endpoint. However, it generates a certificate verification error. I understand that I need to configure a certificate but don't know how. I have succeeded to generate a certificate, but don't know how to configure it in the python library.
from opentelemetry import trace
# from opentelemetry.exporter.jaeger.thrift import JaegerExporter
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
#from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
...
resource = Resource(attributes={
SERVICE_NAME: "demo"
})
provider = TracerProvider(resource=resource)
processor = BatchSpanProcessor(OTLPSpanExporter(endpoint="<endpointhost>/v1/traces", insecure=True))
provider.add_span_processor(processor)
trace.set_tracer_provider(provider)
thanks for any help
答案1
得分: 1
我认为,通过像下面这样提供一个证书文件,我成功解决了这个问题
processor = BatchSpanProcessor(OTLPSpanExporter(endpoint="<ENDPOINTHOST>/v1/traces", certificate_file='证书文件'))
英文:
I think, I managed to resolve the problem by providing a certificate file like below
processor = BatchSpanProcessor(OTLPSpanExporter(endpoint="<ENDPOINTHOST>/v1/traces", certificate_file='CERTIFICATE FILE'))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论