Skip to content

Commit 93a40e7

Browse files
Simplify GCP integration docs (#67)
1 parent e40e843 commit 93a40e7

File tree

1 file changed

+20
-97
lines changed

1 file changed

+20
-97
lines changed

openllmetry/integrations/gcp.mdx

Lines changed: 20 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,45 @@
11
---
2-
title: "LLM Observability with Google Cloud Trace and OpenLLMetry"
2+
title: "LLM Observability with Google Cloud and OpenLLMetry"
33
sidebarTitle: "Google Cloud"
44
---
55

66
[Google Cloud](https://cloud.google.com/?hl=en), also known as Google Cloud Platform (GCP), is a cloud
77
provider including [over 150+ products and services](https://cloud.google.com/products?hl=en). Among
8-
these products and services is [Cloud Trace](https://cloud.google.com/trace/docs), which is a part of the
9-
[Google Cloud Observability](https://cloud.google.com/stackdriver/docs) suite alongside
10-
[Cloud Monitoring](https://cloud.google.com/monitoring/docs) and [Cloud Logging](https://cloud.google.com/logging/docs).
8+
these products and services are [Cloud Trace](https://cloud.google.com/trace/docs),
9+
[Cloud Monitoring](https://cloud.google.com/monitoring/docs), and [Cloud Logging](https://cloud.google.com/logging/docs)
10+
which together comprise [Google Cloud Observability](https://cloud.google.com/stackdriver/docs).
1111

1212
Traceloop's OpenLLMetry library enables instrumenting LLM frameworks in an OTel-aligned manner and
13-
supports writing that instrumentation data as distributed traces to Cloud Trace. Traceloop's OpenLLMetry
14-
library can be additionally configured to also write to Cloud Monitoring and to Cloud Logging.
13+
supports writing that instrumentation data to Google Cloud, primarily as distributed traces in Cloud Trace.
1514

16-
## Minimal Integration: Cloud Trace only
15+
## Integration Instructions
1716

18-
### Dependencies
17+
### Step 1. Install Python Dependencies
1918

20-
- [`opentelemetry-exporter-gcp-trace`](https://pypi.org/project/opentelemetry-exporter-gcp-trace/)
21-
- [`traceloop-sdk`](https://pypi.org/project/traceloop-sdk/)
22-
23-
### OpenLLMetry Configuration
24-
25-
```python
26-
27-
# ...
28-
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
29-
from traceloop.sdk import Traceloop
30-
31-
# ...
32-
trace_exporter = CloudTraceSpanExporter()
33-
Traceloop.init(
34-
app_name='your-app-name',
35-
exporter=trace_exporter)
36-
```
37-
38-
## Integration with Cloud Trace and Cloud Monitoring
39-
40-
### Dependencies
41-
42-
- [`opentelemetry-exporter-gcp-trace`](https://pypi.org/project/opentelemetry-exporter-gcp-trace/)
43-
- [`opentelemetry-exporter-gcp-monitoring`](https://pypi.org/project/opentelemetry-exporter-gcp-monitoring/)
44-
- [`traceloop-sdk`](https://pypi.org/project/traceloop-sdk/)
45-
46-
### OpenLLMetry Configuration
47-
48-
```python
49-
50-
# ...
51-
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
52-
from opentelemetry.exporter.cloud_monitoring import CloudMonitoringMetricsExporter
53-
from traceloop.sdk import Traceloop
54-
55-
# ...
56-
trace_exporter = CloudTraceSpanExporter()
57-
metrics_exporter = CloudMonitoringMetricsExporter()
58-
Traceloop.init(
59-
app_name='your-app-name',
60-
exporter=trace_exporter,
61-
metrics_exporter=metrics_exporter)
19+
```bash
20+
pip install \
21+
opentelemetry-exporter-gcp-trace \
22+
opentelemetry-exporter-gcp-monitoring \
23+
opentelemetry-exporter-gcp-logging \
24+
traceloop-sdk
6225
```
6326

64-
## 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:
27+
### Step 2. Initialize OpenLLMetry
8028

81-
- [`opentelemetry-collector-contrib`](https://hub.docker.com/r/otel/opentelemetry-collector-contrib)
82-
- [`googlecloudexporter`](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/googlecloudexporter/README.md)
83-
84-
#### Python Dependencies
85-
86-
- [`opentelemetry-exporter-gcp-trace`](https://pypi.org/project/opentelemetry-exporter-gcp-trace/)
87-
- [`opentelemetry-exporter-gcp-monitoring`](https://pypi.org/project/opentelemetry-exporter-gcp-monitoring/)
88-
- [`opentelemetry-exporter-otlp-proto-grpc`](https://pypi.org/project/opentelemetry-exporter-otlp-proto-grpc/)
89-
- [`traceloop-sdk`](https://pypi.org/project/traceloop-sdk/)
90-
91-
### OpenLLMetry Configuration
29+
In your application code, invoke `Traceloop.init` as shown:
9230

9331
```python
9432

9533
# ...
96-
from opentelemetry.exporter.otlp.proto.grpc._log_exporter import OTLPLogExporter
34+
from opentelemetry.exporter.cloud_logging import CloudLoggingExporter
9735
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
9836
from opentelemetry.exporter.cloud_monitoring import CloudMonitoringMetricsExporter
9937
from traceloop.sdk import Traceloop
10038

10139
# ...
10240
trace_exporter = CloudTraceSpanExporter()
10341
metrics_exporter = CloudMonitoringMetricsExporter()
104-
105-
# 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()
10943

11044
Traceloop.init(
11145
app_name='your-app-name',
@@ -118,17 +52,6 @@ Traceloop.init(
11852

11953
### Large Span Attributes
12054

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
131-
`Traceloop.init`](https://github.com/GoogleCloudPlatform/generative-ai/blob/b96a0c9ccce165908d5e7262fedcafd9f6fde082/gemini/sample-apps/e2e-gen-ai-app-starter-pack/app/server.py#L64)
132-
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

Comments
 (0)