@@ -936,10 +936,14 @@ def check_token():
936
936
937
937
base_url = self .advanced .generate_base_url (self .token )
938
938
headers ['authorization' ] = self .token
939
- elif self .send_to_logfire is True and self .advanced .base_url is not None :
940
- # We may not need a token if we are sending to a custom
941
- # base URL
942
- base_url = self .advanced .base_url
939
+ elif (
940
+ self .send_to_logfire is True
941
+ and (provided_base_url := self .advanced .base_url ) is not None
942
+ and provided_base_url .startswith ('grpc' )
943
+ ):
944
+ # We may not need a token if we are sending to a grpc
945
+ # endpoint; it could be an otel collector acting as a proxy
946
+ base_url = provided_base_url
943
947
944
948
if base_url is not None :
945
949
if base_url .startswith ('grpc://' ):
@@ -961,9 +965,6 @@ def check_token():
961
965
endpoint = base_url ,
962
966
headers = headers ,
963
967
compression = GrpcCompression .Gzip ,
964
- # I'm pretty sure that this line here is redundant,
965
- # and that passing it to the QuietMetricExporter is what matters
966
- # because the PeriodicExportingMetricReader will read it from there.
967
968
preferred_temporality = METRICS_PREFERRED_TEMPORALITY ,
968
969
)
969
970
log_exporter = GrpcOTLPLogExporter (
@@ -984,9 +985,6 @@ def check_token():
984
985
headers = headers ,
985
986
session = session ,
986
987
compression = Compression .Gzip ,
987
- # I'm pretty sure that this line here is redundant,
988
- # and that passing it to the QuietMetricExporter is what matters
989
- # because the PeriodicExportingMetricReader will read it from there.
990
988
preferred_temporality = METRICS_PREFERRED_TEMPORALITY ,
991
989
)
992
990
log_exporter = OTLPLogExporter (
@@ -1020,6 +1018,11 @@ def check_token():
1020
1018
PeriodicExportingMetricReader (
1021
1019
QuietMetricExporter (
1022
1020
metric_exporter ,
1021
+ # NB this could really be retrieved from `metric_exporter` by `QuietMetricExporter`,
1022
+ # but it is currently a private attribute on `MetricExporter`, we preferred not to reach
1023
+ # inside the otel SDK details.
1024
+ #
1025
+ # Just make sure it always matches.
1023
1026
preferred_temporality = METRICS_PREFERRED_TEMPORALITY ,
1024
1027
)
1025
1028
)
0 commit comments