小编Kil*_*Kem的帖子

使用 Prometheus 检测 Java 应用程序

我正在尝试使用 prometheus java 客户端库监视 java 应用程序中的多个指标,但我在一次监视多个指标时遇到困难。如果我注册并仅抓取一个指标,一切似乎都工作正常,并且我可以使用普罗米修斯应用程序查看该指标,但如果我尝试公开和监控多个指标,则只有其中一个指标可见。

所以如果我有一个带有如下仪表类的应用程序

package com.telemetryserver.Instrumentation;

import io.prometheus.client.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class Instrumented_Class extends HttpServlet
{
    private static Instrumented_Class _instance = null;

    public static final Gauge metric_1 = Gauge.build().name("metric_1").help("metric_1").register();
    //public static final Gauge metric_2 = Gauge.build().name("metric_2").help("metric_2").register();

    public static Instrumented_Class getInstance()
    {
        if (_instance == null)
            _instance = new Instrumented_Class();

        return _instance;
    }

    //Getters and Setters

    public static void setMetric_1(double val) { metric_1.set(val); }

    public static double getMetric_1() { return …
Run Code Online (Sandbox Code Playgroud)

java prometheus

6
推荐指数
1
解决办法
6049
查看次数

为什么WiFiP2P需要互联网许可?

直接引用android网站:

Wi-Fi点对点(P2P)允许具有适当硬件的Android 4.0(API级别14)或更高版本的设备通过Wi-Fi直接相互连接,而无需中间接入点

但根据Android网站,要使用WiFiP2P类,您必须拥有应用程序清单文件的以下权限.

<uses-permission android:name="android.permission.INTERNET" />
Run Code Online (Sandbox Code Playgroud)

我的问题是:如果WiFiP2P直接连接2个Android设备,那为什么需要互联网许可?

java android wifi

4
推荐指数
1
解决办法
87
查看次数

相机预览使用表面纹理

我正在尝试使用SurfaceTexture从我的设备的后置摄像头显示摄像头预览,但我一直收到错误

bindTextureImage:绑定外部纹理图像0x2:0x502的错误

看着说的那条线

SurfaceTexture.UpdateTexImage()
Run Code Online (Sandbox Code Playgroud)

看看android文档,似乎这可能是由于在SurfaceTexture.OnFrameAvailableListenerOnFrameAvailable方法上调用UpdateTexImage引起的.根据文档"可以在任意线程上调用回调(SurfaceTexture.OnFrameAvailableListener),所以它不安全调用updateTexImage()而不先将OpenGL ES上下文绑定到调用回调的线程".

如何"将OpenGL ES上下文绑定"到调用回调的线程?

我一直在努力密切关注Grafika项目中的"相机纹理"活动,试图找到我如何能够完成这项任务的线索.非常感谢.

我的完整代码粘贴在下面:

public class CameraPreviewFromTextureActivity extends Activity 
{
private static String TAG = "CameraPreviewFromTexture";

private static SurfaceHolder mySurfaceHolder = null;    
private SurfaceTexture mCameraTexture = null;   
private Camera mCamera = null;  
private EglCore mEglCore;
private WindowSurface mWindowSurface;
private int mWindowSurfaceWidth;
private int mWindowSurfaceHeight;
private int mCameraPreviewWidth, mCameraPreviewHeight;
private float mCameraPreviewFps;
private Texture2dProgram mTexProgram;

@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_camera_preview_from_texture);

    mySurfaceHolder = ((SurfaceView)this.findViewById(R.id.surfaceView)).getHolder();
    mySurfaceHolder.addCallback(mySurfaceHolderCallback);

    //Run Thread Methods
    mEglCore …
Run Code Online (Sandbox Code Playgroud)

android opengl-es android-camera

3
推荐指数
1
解决办法
6039
查看次数

如何使ScrollViewer在Windows Phone中正常工作

我在我的应用程序页面上添加了一个ScrollViewer对象,并且我在ScrollViewer对象上添加了许多控件对象,但是使用该应用程序的最终用户无法查看所有元素,因为Scroll滚动得不够低,并且页面不断返回在用户有机会输入任何信息之前,它是原始位置.

这是我的XAMLCode:

<phone:PhoneApplicationPage 
    x:Class="WinHomeWork2.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="VOLKOV LTD" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="Agent_App" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <ScrollViewer
         Name="mainScrollViewer"
         Margin="0,175,0,0"
         VerticalScrollBarVisibility="Visible" AllowDrop="False" ManipulationMode="Control">

        <!--ContentPanel - place additional …
Run Code Online (Sandbox Code Playgroud)

.net c# windows-phone-7

2
推荐指数
1
解决办法
1万
查看次数