Skip to content

Commit

Permalink
Remove displayName from API, TCK, Spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Channyboy committed Aug 10, 2022
1 parent 2a882f5 commit 2ca0df3
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 157 deletions.
@@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2018, 2019, 2020 Contributors to the Eclipse Foundation
* Copyright (c) 2018, 2022 Contributors to the Eclipse Foundation
* 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
Expand Down Expand Up @@ -39,15 +39,6 @@ public class DefaultMetadata implements Metadata {
*/
private final String name;

/**
* Display name of the metric. If not set, the name is taken.
* <p>
* An optional field which holds the display (Friendly) name of the metric object. By default it is set to the name
* of the metric object.
* </p>
*/
private final String displayName;

/**
* A human readable description.
* <p>
Expand All @@ -71,10 +62,9 @@ public class DefaultMetadata implements Metadata {
*/
private final String unit;

protected DefaultMetadata(String name, String displayName, String description,
protected DefaultMetadata(String name, String description,
MetricType type, String unit) {
this.name = name;
this.displayName = displayName;
this.description = description;
this.type = type;
this.unit = unit;
Expand All @@ -85,16 +75,6 @@ public String getName() {
return name;
}

@Override
public String getDisplayName() {
return displayName().orElse(name);
}

@Override
public Optional<String> displayName() {
return Optional.ofNullable(displayName);
}

@Override
public String getDescription() {
return description().orElse("");
Expand Down Expand Up @@ -137,15 +117,14 @@ public boolean equals(Object o) {

// Use getters to compare the effective values
return Objects.equals(name, that.getName()) &&
Objects.equals(this.getDisplayName(), that.getDisplayName()) &&
Objects.equals(this.getDescription(), that.getDescription()) &&
Objects.equals(this.getUnit(), that.getUnit()) &&
Objects.equals(this.getTypeRaw(), that.getTypeRaw());
}

@Override
public int hashCode() {
return Objects.hash(name, displayName, description, unit, type);
return Objects.hash(name, description, unit, type);
}

@Override
Expand All @@ -159,11 +138,6 @@ public String toString() {
} else {
sb.append(", description=null");
}
if (displayName != null) {
sb.append(", displayName='").append(displayName).append('\'');
} else {
sb.append(", displayName=null");
}
sb.append('}');
return sb.toString();
}
Expand Down
13 changes: 1 addition & 12 deletions api/src/main/java/org/eclipse/microprofile/metrics/Metadata.java
@@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2017, 2018, 2020 Contributors to the Eclipse Foundation
* Copyright (c) 2017, 2022 Contributors to the Eclipse Foundation
* 2017, 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
Expand Down Expand Up @@ -32,8 +32,6 @@
* The metadata contains:
* <ul>
* <li>{@code Name}: (Required) The name of the metric.</li>
* <li>{@code Display name}: (Optional) The display (friendly) name of the metric. By default, it is set to the
* {@code Name}.</li>
* <li>{@code Description}: (Optional) A human readable description of the metric.</li>
* <li>{@code Type}: (Required) The type of the metric. See {@link MetricType}.</li>
* <li>{@code Unit}: (Optional) The unit of the metric. The unit may be any unit specified as a String or one specified
Expand All @@ -51,15 +49,6 @@ public interface Metadata {
*/
String getName();

/**
* Returns the display name if set, otherwise this method returns the metric name.
*
* @return the display name
*/
String getDisplayName();

Optional<String> displayName();

/**
* Returns the description of the metric if set, otherwise this method returns the empty {@link String}.
*
Expand Down
@@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2018, 2020 Contributors to the Eclipse Foundation
* Copyright (c) 2018, 2022 Contributors to the Eclipse Foundation
* 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
Expand Down Expand Up @@ -34,8 +34,6 @@ public class MetadataBuilder {

private String name;

private String displayName;

private String description;

private MetricType type;
Expand All @@ -47,7 +45,6 @@ public class MetadataBuilder {
this.type = metadata.getTypeRaw();
metadata.description().ifPresent(this::withDescription);
metadata.unit().ifPresent(this::withUnit);
metadata.displayName().ifPresent(this::withDisplayName);
}

public MetadataBuilder() {
Expand All @@ -73,18 +70,6 @@ public MetadataBuilder withName(String name) {
return this;
}

/**
* Sets the displayName.
*
* @param displayName
* the displayName, empty string is considered as "not present" (null)
* @return the builder instance
*/
public MetadataBuilder withDisplayName(String displayName) {
this.displayName = "".equals(displayName) ? null : displayName;
return this;
}

/**
* Sets the description.
*
Expand Down Expand Up @@ -131,6 +116,6 @@ public Metadata build() {
throw new IllegalStateException("Name is required");
}

return new DefaultMetadata(name, displayName, description, type, unit);
return new DefaultMetadata(name, description, type, unit);
}
}
Expand Up @@ -114,16 +114,6 @@
@Nonbinding
boolean absolute() default false;

/**
* The human readable display name of the counter.
*
* @return The display name of the counter.
*
* @see org.eclipse.microprofile.metrics.Metadata
*/
@Nonbinding
String displayName() default "";

/**
* The description of the counter.
*
Expand Down
Expand Up @@ -86,16 +86,6 @@
@Nonbinding
boolean absolute() default false;

/**
* The human readable display name of the gauge.
*
* @return The display name of the gauge.
*
* @see org.eclipse.microprofile.metrics.Metadata
*/
@Nonbinding
String displayName() default "";

/**
* The description of the gauge.
*
Expand Down
Expand Up @@ -84,16 +84,6 @@
@Nonbinding
boolean absolute() default false;

/**
* The display name of the metric.
*
* @return The display name of the metric.
*
* @see org.eclipse.microprofile.metrics.Metadata
*/
@Nonbinding
String displayName() default "";

/**
* The description of the metric.
*
Expand Down
Expand Up @@ -108,16 +108,6 @@
@Nonbinding
boolean absolute() default false;

/**
* The display name of the timer.
*
* @return The display name of the timer.
*
* @see org.eclipse.microprofile.metrics.Metadata
*/
@Nonbinding
String displayName() default "";

/**
* The description of the timer.
*
Expand Down
Expand Up @@ -36,7 +36,7 @@
* <p>
* MicroProfile Metrics provides 4 different metric types that can be used to instrument an application. Developers can
* create an accompanying {@link org.eclipse.microprofile.metrics.Metadata Metadata} object to supply the metric's name,
* description, display name, and units. Once the metric and the metadata are registered against the application
* description and units. Once the metric and the metadata are registered against the application
* {@link org.eclipse.microprofile.metrics.MetricRegistry MetricRegistry}, the metrics will be available in the REST
* endpoints.
*
Expand Down
1 change: 0 additions & 1 deletion spec/src/main/asciidoc/app-programming-model.adoc
Expand Up @@ -117,7 +117,6 @@ in <<architecture#meta-data-def>>.
`String name`:: Optional. Sets the name of the metric. If not explicitly given the name of the annotated object is used.
`boolean absolute`:: If `true`, uses the given name as the absolute name of the metric.
If `false`, prepends the package name and class name before the given name. Default value is `false`.
`String displayName`:: Optional. A human readable display name for metadata.
`String description`:: Optional. A description of the metric.
`String unit`:: Unit of the metric. For `@Gauge` no default is provided. Check the `MetricUnits` class for a set of pre-defined units.
`String scope`:: Optional. The `MetricRegistry` scope that this metric belongs to. Default value is `application`.
Expand Down
1 change: 0 additions & 1 deletion spec/src/main/asciidoc/appendix.adoc
Expand Up @@ -51,7 +51,6 @@ base:
description: "Number of currently deployed threads"
unit: "none"
type: "gauge"
displayName: "Current Thread count"
- name: "peak-thread-count"
mbean: "java.lang:type=Threading/PeakThreadCount"
description: "Max number of threads"
Expand Down
2 changes: 0 additions & 2 deletions spec/src/main/asciidoc/architecture.adoc
Expand Up @@ -174,8 +174,6 @@ The Metadata:
** histogram: a metric which calculates the distribution of a value.
** timer: a metric which aggregates timing durations and provides duration statistics.
* description (optional): A human readable description of the metric.
* displayName (optional): A human readable name of the metric for display purposes if the metric name is not
human readable. This could e.g. be the case when the metric name is a uuid.

Metadata must not change over the lifetime of a process (i.e. it is not allowed
to return the units as seconds in one retrieval and as hours in a subsequent one).
Expand Down

0 comments on commit 2ca0df3

Please sign in to comment.