class ProjectContext
Defined at line 64 of file ../../third_party/cobalt/src/logger/project_context.h
ProjectContext stores the metrics registration data for a single Cobalt
project and makes it conveniently available on the client.
The underlying data comes from a |ProjectConfig| proto message which
represents a single project within the Cobalt Registry. An instance of
ProjectContext does not copy the data from a |ProjectConfig|, but rather
maintains a pointer to an instance of |ProjectConfig|. An instance of
ProjectContext may or may not own its underlying |ProjectConfig|, depending
on which constructor is used.
Public Methods
void ProjectContext (uint32_t customer_id, const std::string & customer_name, std::unique_ptr<ProjectConfig> project_config)
Constructs an instance of ProjectContext that does own the
underlying |ProjectConfig|.
|customer_id| The id of the customer this project is for.
|customer_name| The name of the customer this project is for.
|project_config| The |ProjectConfig| containing the project data.
void ProjectContext (uint32_t customer_id, const std::string & customer_name, const ProjectConfig * project_config)
Constructs an instance of ProjectContext that does not own the
underlying |ProjectConfig|.
|customer_id| The id of the customer this project is for.
|customer_name| The name of the customer this project is for.
|project_config| The |ProjectConfig| containing the project data.
const MetricDefinition * GetMetric (const std::string & metric_name)
Returns the MetricDefinition for the metric with the given name, or
nullptr if there is no such metric.
const MetricDefinition * GetMetric (uint32_t metric_id)
Returns the MetricDefinition for the metric with the given ID, or
nullptr if there is no such metric.
const MetricDefinition * GetMetric (lib::MetricIdentifier metric)
Defined at line 95 of file ../../third_party/cobalt/src/logger/project_context.h
MetricRef RefMetric (const MetricDefinition * metric_definition)
Makes a MetricRef that wraps this ProjectContext's Project and the given
metric_definition (which should have been obtained via GetMetric()).
The Project and MetricDefinition must remain valid as long as the returned
MetricRef is being used.
std::string DebugString ()
std::string FullyQualifiedName (const Project & project)
Returns the string
<customer
_name>(
<id
>).
<project
_name>(
<id
>)
std::string FullMetricName (const Project & project, const MetricDefinition & metric)
Returns the string
<customer
_name>(
<id
>).
<project
_name>(
<id
>).
<metric
_name>(
<id
>)
std::string FullyQualifiedName ()
Returns the string
<customer
_name>(
<id
>).
<project
_name>(
<id
>)
std::string FullMetricName (const MetricDefinition & metric_definition)
Returns the string
<customer
_name>(
<id
>).
<project
_name>(
<id
>).
<metric
_name>(
<id
>)
std::vector<lib::MetricIdentifier> ListMetrics ()
ListMetrics returns a list of metric identifiers that are present in this project.
lib::ProjectIdentifier Identifier ()
const Project & project ()
Gives access to the metadata for the project.
Defined at line 106 of file ../../third_party/cobalt/src/logger/project_context.h
const google::protobuf::RepeatedPtrField<MetricDefinition> & metrics ()
Gives access to the list of all MetricDefinitions for the project.
Defined at line 109 of file ../../third_party/cobalt/src/logger/project_context.h