Skip to content

🐛 Bug Report: No way to set use_legacy_attributes using TraceLoop.init() #3236

@josephwangrb

Description

@josephwangrb

Which component is this bug for?

OpenAI Instrumentation

📜 Description

What's the issue?

Although most of the instrumentors support the flag use_legacy_attributes to emit prompts input&output as events, there is no way to pass this flag through TraceLoop.init().

People have to init traceProvider, logProvider, metricProvider manually, and list down all the instrumentors that are needed.

# 1. Define Resource
resource = Resource(attributes={SERVICE_NAME: "ying-test"})

# 2. configure trace provider
tracer_provider = TracerProvider(resource=resource)
trace.set_tracer_provider(tracer_provider)
span_exporter = OTLPSpanExporterHTTP(endpoint="http://127.0.0.1:4320/v1/traces")
tracer_provider.add_span_processor(BatchSpanProcessor(span_exporter))

# 3 configure log provider
logger_provider = LoggerProvider(resource=resource)
_logs.set_logger_provider(logger_provider)
log_exporter = OTLPLogExporterHTTP(endpoint="http://127.0.0.1:4320/v1/logs")
logger_provider.add_log_record_processor(BatchLogRecordProcessor(log_exporter))

OpenAIInstrumentor(
    use_legacy_attributes=False,
).instrument(
    event_logger_provider=EventLoggerProvider()
)

What's the root cause?

  1. The function Traceloop.init() does not allow this flag as an argument.
  2. When we init instrumentors here, there is no parameter for use_legacy_attributes.

Why is this a Bug rather than feature request?

As we have closed this issue, people expect this feature is supported through TraceLoop whereas it is not due to no way to configure it.

👟 Reproduction steps

When we tried to send input&output as event, we met this issue.

👍 Expected behavior

Traceloop.init(use_legacy_attributes=False)

👎 Actual Behavior with Screenshots

# 1. Define Resource
resource = Resource(attributes={SERVICE_NAME: "ying-test"})

# 2. configure trace provider
tracer_provider = TracerProvider(resource=resource)
trace.set_tracer_provider(tracer_provider)
span_exporter = OTLPSpanExporterHTTP(endpoint="http://127.0.0.1:4320/v1/traces")
tracer_provider.add_span_processor(BatchSpanProcessor(span_exporter))

# 3 configure log provider
logger_provider = LoggerProvider(resource=resource)
_logs.set_logger_provider(logger_provider)
log_exporter = OTLPLogExporterHTTP(endpoint="http://127.0.0.1:4320/v1/logs")
logger_provider.add_log_record_processor(BatchLogRecordProcessor(log_exporter))

OpenAIInstrumentor(
    use_legacy_attributes=False,
).instrument(
    event_logger_provider=EventLoggerProvider()
)

🤖 Python Version

No response

📃 Provide any additional context for the Bug.

Please also advice how should we create the EventLoggerProvider? should we set it as an argument for Traceloop.init or, we just create it when use_legacy_attributes is set to False.

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

Are you willing to submit PR?

Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions