1 | /**
|
2 | * Copyright 2018, OpenCensus Authors
|
3 | *
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | */
|
16 | import { Resource } from './types';
|
17 | /**
|
18 | * Resource represents a resource, which capture identifying information about
|
19 | * the entities for which signals (stats or traces) are reported. It further
|
20 | * provides a framework for detection of resource information from the
|
21 | * environment and progressive population as signals propagate from the core
|
22 | * instrumentation library to a backend's exporter.
|
23 | */
|
24 | export declare class CoreResource {
|
25 | private static readonly MAX_LENGTH;
|
26 | private static readonly COMMA_SEPARATOR;
|
27 | private static readonly LABEL_KEY_VALUE_SPLITTER;
|
28 | private static ENV_TYPE;
|
29 | private static ENV_LABEL_MAP;
|
30 | private static readonly ERROR_MESSAGE_INVALID_CHARS;
|
31 | private static readonly ERROR_MESSAGE_INVALID_VALUE;
|
32 | /**
|
33 | * Returns a Resource. This resource information is loaded from the
|
34 | * OC_RESOURCE_TYPE and OC_RESOURCE_LABELS environment variables.
|
35 | *
|
36 | * @returns The resource.
|
37 | */
|
38 | static createFromEnvironmentVariables(): Resource;
|
39 | /**
|
40 | * Returns a Resource that runs all input resources sequentially and merges
|
41 | * their results. In case a type of label key is already set, the first set
|
42 | * value takes precedence.
|
43 | *
|
44 | * @param resources The list of the resources.
|
45 | * @returns The resource.
|
46 | */
|
47 | static mergeResources(resources: Resource[]): Resource;
|
48 | /**
|
49 | * Creates a resource type from the OC_RESOURCE_TYPE environment variable.
|
50 | *
|
51 | * OC_RESOURCE_TYPE: A string that describes the type of the resource
|
52 | * prefixed by a domain namespace, e.g. “kubernetes.io/container”.
|
53 | *
|
54 | * @param rawEnvType The resource type.
|
55 | * @returns The sanitized resource type.
|
56 | */
|
57 | private static parseResourceType;
|
58 | /**
|
59 | * Creates a label map from the OC_RESOURCE_LABELS environment variable.
|
60 | *
|
61 | * OC_RESOURCE_LABELS: A comma-separated list of labels describing the
|
62 | * source in more detail, e.g. “key1=val1,key2=val2”. Domain names and paths
|
63 | * are accepted as label keys. Values may be quoted or unquoted in general. If
|
64 | * a value contains whitespaces, =, or " characters, it must always be quoted.
|
65 | *
|
66 | * @param rawEnvLabels The resource labels as a comma-seperated list
|
67 | * of key/value pairs.
|
68 | * @returns The sanitized resource labels.
|
69 | */
|
70 | private static parseResourceLabels;
|
71 | /**
|
72 | * Returns a new, merged Resource by merging two resources. In case of
|
73 | * a collision, first resource takes precedence.
|
74 | *
|
75 | * @param resource The resource object.
|
76 | * @param otherResource The resource object.
|
77 | * @returns A new, merged Resource.
|
78 | */
|
79 | private static merge;
|
80 | /**
|
81 | * Determines whether the given String is a valid printable ASCII string with
|
82 | * a length not exceed MAX_LENGTH characters.
|
83 | *
|
84 | * @param str The String to be validated.
|
85 | * @returns Whether the String is valid.
|
86 | */
|
87 | private static isValid;
|
88 | /**
|
89 | * Determines whether the given String is a valid printable ASCII string with
|
90 | * a length greater than 0 and not exceed MAX_LENGTH characters.
|
91 | *
|
92 | * @param str The String to be validated.
|
93 | * @returns Whether the String is valid and not empty.
|
94 | */
|
95 | private static isValidAndNotEmpty;
|
96 | /** TEST_ONLY */
|
97 | static setup(): void;
|
98 | }
|