Skip to content

Commit

Permalink
project_id not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Xue committed May 28, 2020
1 parent 59473ae commit 0a145fa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ext/opentelemetry-ext-cloud-trace/examples/basic_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

trace.set_tracer_provider(TracerProvider())

cloud_trace_exporter = CloudTraceSpanExporter(project_id="my-gcloud-project")
cloud_trace_exporter = CloudTraceSpanExporter()
trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(cloud_trace_exporter)
)
Expand Down
2 changes: 1 addition & 1 deletion ext/opentelemetry-ext-cloud-trace/examples/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

trace.set_tracer_provider(TracerProvider())

cloud_trace_exporter = CloudTraceSpanExporter(project_id="my-gcloud-project")
cloud_trace_exporter = CloudTraceSpanExporter()
trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(cloud_trace_exporter)
)
Expand Down
2 changes: 1 addition & 1 deletion ext/opentelemetry-ext-cloud-trace/examples/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

trace.set_tracer_provider(TracerProvider())

cloud_trace_exporter = CloudTraceSpanExporter(project_id="my-gcloud-project")
cloud_trace_exporter = CloudTraceSpanExporter()
trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(cloud_trace_exporter)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from google.cloud.trace_v2.proto.trace_pb2 import Span as ProtoSpan
from google.cloud.trace_v2.proto.trace_pb2 import TruncatableString
from google.rpc.status_pb2 import Status
import google.auth

import opentelemetry.trace as trace_api
from opentelemetry.sdk.trace import Event
Expand All @@ -44,10 +45,13 @@ class CloudTraceSpanExporter(SpanExporter):
"""

def __init__(
self, project_id, client=None,
self, project_id=None, client=None,
):
self.client = client or TraceServiceClient()
self.project_id = project_id
if not project_id:
_, self.project_id = google.auth.default()
else:
self.project_id = project_id

def export(self, spans: Sequence[Span]) -> SpanExportResult:
"""Export the spans to Cloud Trace.
Expand Down

0 comments on commit 0a145fa

Please sign in to comment.