blob: 9b7e166413669270dc4e65254b9fe40a25074cdf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/*
* Copyright 2017, OpenCensus Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.opencensus.trace.export;
import io.opencensus.trace.TraceOptions;
import javax.annotation.Nullable;
/**
* Class that holds the implementation instances for {@link SpanExporter}, {@link RunningSpanStore}
* and {@link SampledSpanStore}.
*
* <p>Unless otherwise noted all methods (on component) results are cacheable.
*/
public abstract class ExportComponent {
private static final NoopExportComponent NOOP_EXPORT_COMPONENT = new NoopExportComponent();
/**
* Returns the no-op implementation of the {@code ExportComponent}.
*
* @return the no-op implementation of the {@code ExportComponent}.
*/
public static ExportComponent getNoopExportComponent() {
return NOOP_EXPORT_COMPONENT;
}
/**
* Returns the {@link SpanExporter} which can be used to register handlers to export all the spans
* that are part of a distributed sampled trace (see {@link TraceOptions#isSampled()}).
*
* @return the implementation of the {@code SpanExporter} or no-op if no implementation linked in
* the binary.
*/
public abstract SpanExporter getSpanExporter();
/**
* Returns the {@link RunningSpanStore} that can be used to get useful debugging information about
* all the current active spans.
*
* @return the {@code RunningSpanStore} or {@code null} if not supported.
*/
@Nullable
public abstract RunningSpanStore getRunningSpanStore();
/**
* Returns the {@link SampledSpanStore} that can be used to get useful debugging information, such
* as latency based sampled spans, error based sampled spans.
*
* @return the {@code SampledSpanStore} or {@code null} if not supported.
*/
@Nullable
public abstract SampledSpanStore getSampledSpanStore();
private static final class NoopExportComponent extends ExportComponent {
@Override
public SpanExporter getSpanExporter() {
return SpanExporter.getNoopSpanExporter();
}
@Nullable
@Override
public RunningSpanStore getRunningSpanStore() {
return null;
}
@Nullable
@Override
public SampledSpanStore getSampledSpanStore() {
return null;
}
}
}
|