Skip to content
This repository was archived by the owner on Nov 7, 2022. It is now read-only.

Commit 73558e6

Browse files
draffenspergersongy23
authored andcommitted
Set default project when on GCP (#526)
1 parent eef0179 commit 73558e6

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ exporters:
165165
topic: "opencensus-spans"
166166

167167
stackdriver:
168-
project: "your-project-id"
168+
project: "my-project-id" # optional, defaults to agent project if run on GCP
169169
enable_tracing: true
170170

171171
zipkin:

cmd/ocagent/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ receivers:
77

88
exporters:
99
stackdriver:
10-
project: "project-id"
10+
project: "project-id" # Optional if on GCP, defaults to agent project
1111
enable_tracing: true
1212

1313
zipkin:

exporter/stackdriverexporter/stackdriver.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ func StackdriverTraceExportersFromViper(v *viper.Viper) (tps []consumer.TraceCon
6262

6363
// TODO: For each ProjectID, create a different exporter
6464
// or at least a unique Stackdriver client per ProjectID.
65-
if sc.ProjectID == "" {
66-
return nil, nil, nil, fmt.Errorf("Stackdriver config requires a project ID")
67-
}
6865

6966
sde, serr := stackdriver.NewExporter(stackdriver.Options{
70-
ProjectID: sc.ProjectID,
67+
// If the project ID is an empty string, it will be set by default based on
68+
// the project this is running on in GCP.
69+
ProjectID: sc.ProjectID,
70+
7171
MetricPrefix: sc.MetricPrefix,
7272

7373
// Stackdriver Metrics mandates a minimum of 60 seconds for

0 commit comments

Comments
 (0)