You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Integration with Cloud Trace, Cloud Monitoring, and Cloud Logging
65
-
66
-
As of 2024-12-05, there is no direct Python OTel exporter for Cloud Logging. However,
67
-
it is possible to work around this by routing to the [OTel Collector](https://opentelemetry.io/docs/collector/)
68
-
and using the [`googlecloudexporter`](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/googlecloudexporter/README.md)
69
-
in the OTel Collector to route logs to Google Cloud Logging. Alternatively, you
70
-
can use the Python [`ConsoleLogExporter`](https://github.com/open-telemetry/opentelemetry-python/blob/415c94fb9834ce38459e58d5ee192a98494c4c76/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/__init__.py#L86)
71
-
to log to a file in conjunction with automatic file-based log routing such as via
72
-
the [Ops Agent](https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent),
73
-
direct use of [FluentBit](https://fluentbit.io/), or other routing solutions.
74
-
75
-
### Dependencies
76
-
77
-
#### OTel Dependencies
78
-
79
-
This is assuming that you write to Cloud Logging via the OTel Collector:
# Will use the 'OTEL_EXPORTER_OTLP_LOGS_*' environment
106
-
# variables (such as 'OTEL_EXPORTER_OTLP_LOGS_ENDPOINT')
107
-
# to select how to connect to the OTel Collector.
108
-
logs_exporter = OTLPLogExporter()
42
+
logs_exporter = CloudLoggingExporter()
109
43
110
44
Traceloop.init(
111
45
app_name='your-app-name',
@@ -118,17 +52,6 @@ Traceloop.init(
118
52
119
53
### Large Span Attributes
120
54
121
-
Although [OTel Semantic Conventions](https://opentelemetry.io/docs/concepts/semantic-conventions/)
122
-
[for GenAI](https://opentelemetry.io/docs/specs/semconv/gen-ai/) has been moving
123
-
from prompt/response logging in span attributes to recording prompts/responses in
124
-
events (logs) -- see [related pull request](https://github.com/open-telemetry/semantic-conventions/pull/980)
125
-
--, some versions of OpenLLMetry and related instrumentation packages follow older
126
-
experimental conventions of recording prompts/responses in span attributes which do
127
-
not fit within [Cloud Trace limits](https://cloud.google.com/trace/docs/quotas).
128
-
129
-
The [`e2e-gen-ai-app-starter-pack`](https://github.com/GoogleCloudPlatform/generative-ai/tree/b96a0c9ccce165908d5e7262fedcafd9f6fde082/gemini/sample-apps/e2e-gen-ai-app-starter-pack)
130
-
code sample provided by Google illustrates a potential workaround; that app, [calls
with a custom [`CloudTraceLoggingSpanExporter`](https://github.com/GoogleCloudPlatform/generative-ai/blob/b96a0c9ccce165908d5e7262fedcafd9f6fde082/gemini/sample-apps/e2e-gen-ai-app-starter-pack/app/utils/tracing.py#L26)
133
-
which inherits from the official `CloudTraceSpanExporter` and adds additional capabilities
134
-
for handling large span attributes.
55
+
You can use the [`CloudTraceLoggingSpanExporter`](https://github.com/GoogleCloudPlatform/agent-starter-pack/blob/3dfb0c444aa70a3b0c62313c4cba14f9bc9d1723/src/base_template/app/utils/tracing.py)
56
+
from the [Google Cloud `agent-starter-pack`](https://github.com/GoogleCloudPlatform/agent-starter-pack) as a drop-in replacement for the
57
+
`CloudTraceSpanExporter`. That exporter writes large attributes to Google Cloud Storage and writes a reference URL to Cloud Observability.
0 commit comments